package com.jg.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;

import javax.sql.DataSource;

/**
 * @author 86130
 * @version 1.0
 * @description: TODO
 * @date 2025/9/2 上午10:40
 */
public class JdbcConfig {
    @Value("${driver}")
    private String driver;
    @Value("${url}")
    private String url;
    @Value("${uname}")
    private String uname;
    @Value("${pwd}")
    private String pwd;

    @Bean
    public DataSource getDataSource() {
        // 创建数据源
        DruidDataSource dataSource = new DruidDataSource();
        // 设置驱动
        dataSource.setDriverClassName(driver);
        // 设置连接地址
        dataSource.setUrl(url);
        // 设置用户名
        dataSource.setUsername(uname);
        // 设置密码
        dataSource.setPassword(pwd);
        return dataSource;
    }
}
